package com.oocl.heather.Service.impl;

import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;
import java.util.Set;
import java.util.TreeSet;

import com.oocl.heather.Service.IParser;
import com.oocl.heather.comparator.ICustomerComparator;
import com.oocl.heather.comparator.impl.CustomerIdComparator;
import com.oocl.heather.entity.Customer;

public class Parser implements IParser {
//分析器
	@Override
	public Set<Customer> parse(List<String> list, ICustomerComparator co) {
		// TODO Auto-generated method stub
		Set<Customer> p=new TreeSet<Customer>(new CustomerIdComparator());
		DateFormat format=new SimpleDateFormat("yyyy-MM-dd");
		for (int i = 0; i < list.size(); i++) {
			String[] s=list.get(i).split("\t");
			
			Customer cs=new Customer();
			try {
				
				cs.setId(Integer.valueOf(s[0]));
				cs.setName(s[1]);
				Date birth;
				birth = format.parse(s[2]);
				cs.setBirth(birth);
				cs.setSex(s[3]);
				cs.setEmail(s[4]);
				p.add(cs);
				
			} catch (ParseException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
			
		}
		
		
		return p;
	}

}
